package com.wechat.back.mapper;

import com.wechat.back.pojo.inform.Message;
import com.wechat.back.pojo.inform.MsgState;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface MsgMapper {
    @Select("select * from message where msg_sign=#{msgSign}")
    List<Message> findBySign(Integer msgSign);

    @Select("select * from message")
    List<Message> findAll();

    @Insert("insert into message(sender, sender_id, receiver, receiver_id, content, msg_time, known_state, msg_sign) " +
            "values (#{sender}, #{senderId},#{receiver},#{receiverId},#{content},#{msgTime},#{knownState},#{msgSign})")
    void addMsg(Message message);

    @Insert("insert into message_state(user_id, user, create_time) " +
            "VALUES (#{userId},#{user},#{createTime})")
    void addMsgState(MsgState msgState);

    @Select("select * from message_state where user_id=#{userId}")
    MsgState findMsgStateByUserId(Integer userId);

    List<MsgState> findAllMsgState(String user);
}
